// 引入std
use std::{io, cmp::Ordering};
use rand::Rng;
// use core::cmp::Ordering;
fn main() {
    println!("Game Start");

    // let sum = 244u8.checked_add(200);
    // assert_eq!(sum.is_some(), true);
    // println!("{}", sum.is_some());
    let secret_number = rand::thread_rng().gen_range(1..=100);
    println!("You SecretNumbeer is {secret_number}");
    println!("Please input number!");
    loop {
        // 定义一个变量
        let mut guess = String::new();
        // 传入可变变量获取值
        io::stdin().read_line(&mut guess)
        .expect("Failed to read line");
    
        let guess: u32 = guess.trim().parse().expect("please type a number");
        println!("you number is {guess}");
    
        match guess.cmp(&secret_number) {
            Ordering::Equal => {
                println!("You Win");
                break;
            },
            Ordering::Less => println!("Too Small"),
            Ordering::Greater => println!("Too Large"),
        }

    }
}
